package restaurant;

/**
 * Represents items on the menu. This class contains information about the items
 * stored in the restaurant's menu.
 * 
 * @author Odessa
 */

public class MenuItem
{

	/** The item number of this item. */
	private int itemNo;

	/** The item name of this item. */
	private String name;

	/** The description of this item. */
	private String description;

	/** The normal price of this item. */
	private double normalPrice;

	/** The normal time it takes to prepare this item. */
	private int normalPrepTime;

	/** This item's course. */
	private String course;

	/** This item's status as vegetarian. */
	private boolean vegetarian;

	/** This item's rating. */
	private double rating = 0;

	/** The current price of this item. */
	private double currentPrice;

	/** The current time it will take to prepare this item. */
	private int currentPrepTime;

	/** This item's availability status. */
	private boolean available;

	/** The number of this item that is available. */
	private int numAvailable = 0;



	/**
	 * Instantiates a newly created menu item. When an item is created, the
	 * current price and the current preparation time is the same as the normal
	 * price and normal preparation time.
	 * 
	 * @param itemNo the item number of the menu item to be created. Cannot be
	 *            null.
	 * @param name the name of this item.
	 * @param description a description of this item.
	 * @param price the normal price of this item.
	 * @param prepTime the normal time to prepare this item.
	 * @param course this item's course.
	 * @param vegetarian true for vegetarian items.
	 */
	public MenuItem(int itemNo, String name, String description, double price,
			int prepTime, String course, boolean vegetarian) {
		this.itemNo = itemNo;
		this.name = name;
		this.description = description;
		normalPrice = price;
		normalPrepTime = prepTime;
		this.course = course;
		this.vegetarian = vegetarian;
		currentPrice = price;
		currentPrepTime = prepTime;
	}



	/**
	 * Gets the item number of this menu item. The item number is used to
	 * uniquely identify each menu item.
	 * 
	 * @return the item number.
	 */
	public int getItemNo()
	{
		return itemNo;
	}



	/**
	 * Gets this item's name.
	 * 
	 * @return the name of this item.
	 */
	public String getName()
	{
		return name;
	}



	/**
	 * Gets a description of this item.
	 * 
	 * @return the description of this item.
	 */
	public String getDescription()
	{
		return description;
	}



	/**
	 * Gets the normal price of this item.
	 * 
	 * @return the normal price of this item.
	 */
	public double getNormalPrice()
	{
		return normalPrice;
	}



	/**
	 * Gets the normal time it takes to prepare this item.
	 * 
	 * @return the normal preparation time of this item.
	 */
	public int getNormalPrepTime()
	{
		return normalPrepTime;
	}



	/**
	 * Gets this item's course.
	 * 
	 * @return the item's course.
	 */
	public String getCourse()
	{
		return course;
	}



	/**
	 * Checks if this item is vegetarian.
	 * 
	 * @return {@code true} if this item is vegetarian.
	 */
	public boolean isVegetarian()
	{
		return vegetarian;
	}



	/**
	 * Gets this item's rating.
	 * 
	 * @return the item's rating.
	 */
	public double getRating()
	{
		return rating;
	}



	/**
	 * Gets the current price of this item.
	 * 
	 * @return the current price of this item.
	 */
	public double getCurrentPrice()
	{
		return currentPrice;
	}



	/**
	 * Gets the current preparation time of this item.
	 * 
	 * @return the time to currently prepare this item.
	 */
	public int getCurrentPrepTime()
	{
		return currentPrepTime;
	}



	/**
	 * Checks if this item is available. First calls {@code itemAvailability} to
	 * determine if this item is available.
	 * 
	 * @return {@code true} if this item is available.
	 */
	public boolean isAvailable()
	{
		itemAvailability();

		return available;
	}



	/**
	 * Sets the rating of this item.
	 * 
	 * @param rating the new rating of this item.
	 */
	public void setRating(double rating)
	{
		this.rating = rating;
	}



	/**
	 * Sets the current price of this item.
	 * 
	 * @param price the current price of this item.
	 */
	public void setCurrentPrice(double price)
	{
		currentPrice = price;
	}



	/**
	 * Sets the current preparation time of this item.
	 * 
	 * @param time the current preparation time of this item.
	 */
	public void setCurrentPrepTime(int time)
	{
		currentPrepTime = time;
	}



	/**
	 * Sets the number of this item that is available for the evening.
	 * 
	 * @param numAvailable the number of this item that is available.
	 */
	public void setNumAvailable(int numAvailable)
	{
		this.numAvailable = numAvailable;
	}



	/**
	 * Sets the availability of this item. The item is only {@code available} if
	 * the {@code numAvailable} is more than zero.
	 */
	private void itemAvailability()
	{
		if (numAvailable > 0)
			available = true;
		else
			available = false;
	}

}
